/**
 * @filename:CategoryServiceImpl Category
 * @project constract  V1.0
 * Copyright(c) 2018 lin keqing Co. Ltd.
 * All right reserved.
 */
package com.znufe.exam.service.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.znufe.exam.repository.CategoryMapper;
import com.znufe.exam.viewmodel.admin.category.AllCategoryInfoResponseVM;
import com.znufe.exam.viewmodel.admin.category.CategoryPageRequestVM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.znufe.exam.domain.Category;
import com.znufe.exam.repository.CategoryMapper;
import com.znufe.exam.service.CategoryService;

/**
 *
 * @Description:  类别信息表——SERVICEIMPL
 * @Author:       lin keqing
 * @CreateDate:   Category
 * @Version:      V1.0
 *
 */
@Service
public class CategoryServiceImpl extends BaseServiceImpl<Category> implements CategoryService {

	private final CategoryMapper categoryMapper;

	@Autowired
	public CategoryServiceImpl(CategoryMapper categoryMapper) {
		super(categoryMapper);
		this.categoryMapper = categoryMapper;
	}

	//查询对象
	@Override
	public Category selectByPrimaryKey(Integer id) {
		return categoryMapper.selectByPrimaryKey(id);
	}

	public Category selectByConcreteName(String concreteName) {
		return categoryMapper.selectByConcreteName(concreteName);
	}

	//删除对象
	@Override
	public int deleteByPrimaryKey(Integer id) {
		return categoryMapper.deleteByPrimaryKey(id);
	}

	//添加对象
	@Override
	public int insertSelective(Category category) {
		return categoryMapper.insertSelective(category);
	}

	//修改对象
	@Override
	public int updateByPrimaryKeySelective(Category category) {
		return categoryMapper.updateByPrimaryKeySelective(category);
	}

	//查询集合
	@Override
	public List<Category> queryCategoryList(Category category) {

		return categoryMapper.queryCategoryList(category);
	}

	@Override
	public List<AllCategoryInfoResponseVM> queryAllCategoryInfoList(Integer categoryId) {
		return categoryMapper.queryAllCategoryInfoList(categoryId);
	}

	// 选择查询类别信息（按名称查找）
	@Override
    public PageInfo<Category> categoryPage(CategoryPageRequestVM requestVM) {
		return PageHelper.startPage(requestVM.getPageNum(), requestVM.getPageSize(),
					"id desc").doSelectPageInfo(() ->
					categoryMapper.categoryPage(requestVM));
	}

    @Override
    public List<Category> getAllType() {
        return categoryMapper.getAllType();
    }
}
